﻿using System;
using System.Collections.Generic;

namespace Student
{
    class Student: ICloneable, IComparable<Student>
    {
        private string firstName;
        private string surname;
        private string lastName;
        private string ssn;
        private string mobile;
        private string email;
        private int course;
        private List<string> specialities;
        private List<string> universties;
        private List<string> faculties;

        public Student() { }

        public Student(string firstName, string surname,string lastName, string mobile,string SSN) 
        {
            this.firstName = firstName;
            this.surname = surname;
            this.lastName = lastName;
            this.ssn = SSN;
            this.mobile = mobile;
            this.email = null;
            this.course = 0;
            this.specialities = new List<string>();
            this.universties = new List<string>();
            this.faculties = new List<string>();
        }

        public int CompareTo(Student other)
        {
            int result = this.FirstName.CompareTo(other.FirstName);
            if (result == 0) 
            {
                result = this.Surname.CompareTo(other.Surname);
            }
            if (result == 0) 
            {
                result = this.LastName.CompareTo(other.LastName);
            }
            if (result == 0)
            {
                result = this.ssn.CompareTo(other.ssn);
            }

            return result;
        }

        public object Clone()
        {
            Student outStudent = new Student();
            outStudent.firstName = this.FirstName;
            outStudent.surname = this.surname;
            outStudent.lastName = this.lastName;
            outStudent.mobile = this.mobile;
            outStudent.ssn = this.ssn;

            return outStudent;
        }

        public override bool Equals(object obj)
        {
            Student otherStudent = obj as Student;

            if (otherStudent == null) 
            {
                return false;
            }

            return string.Equals(this.ssn, otherStudent.ssn);
        }

        public static bool operator ==(Student firstStudent, Student secondStudent) 
        {
            return Student.Equals(firstStudent, secondStudent);
        }
        public static bool operator !=(Student firstStudent, Student secondStudent) 
        {
            return !Student.Equals(firstStudent, secondStudent);
        }

        public override int GetHashCode()
        {
            return this.Mobile.GetHashCode() * this.ssn.GetHashCode();
        }

        public override string ToString()
        {
            string text = "First name: " + this.FirstName + "\n" +
                "Surname: " + this.Surname + "\n" +
                "Last Name: " + this.LastName;
            return text;
        }

        public List<string> Faculties
        {
            get
            {
                return faculties;
            }
            set
            {
                faculties = value;
            }
        }

        public List<string> Universties
        {
            get
            {
                return universties;
            }
            set
            {
                universties = value;
            }
        }

        public List<string> Specialities
        {
            get
            {
                return specialities;
            }
            set
            {
                specialities = value;
            }
        }

        public int Course
        {
            get
            {
                return course;
            }
            set
            {
                course = value;
            }
        }

        public string Email
        {
            get
            {
                return email;
            }
            set
            {
                email = value;
            }
        }

        public string Mobile
        {
            get
            {
                return mobile;
            }
            set
            {
                mobile = value;
            }
        }

        public string PSSN
        {
            get
            {
                return ssn;
            }
            set
            {
                ssn = value;
            }
        }

        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                lastName = value;
            }
        }

        public string Surname
        {
            get
            {
                return surname;
            }
            set
            {
                surname = value;
            }
        }

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                firstName = value;
            }
        }
    }
}
